﻿//        Another Demo from Andy L. & MissedMemo.com
// Borrow whatever code seems useful - just don't try to hold
// me responsible for any ill effects. My demos sometimes use
// licensed images which CANNOT legally be copied and reused.

using System.ComponentModel;


namespace MissedMemo.MeatAndCheeseDisc.BusinessLogic
{
    public class Customer : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private string  _name = "( walk-in customer )";
        private Address _address = new Address();
        private string  _email;
        private string  _phone;
        private string  _fax;


    #region Properties...

        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                Notify( "Name" );
            }
        }

        public string EMail
        {
            get { return _email; }
            set
            {
                _email = value;
                Notify( "EMail" );
            }
        }

        public string Phone
        {
            get { return _phone; }
            set
            {
                _phone = value;
                Notify( "Phone" );
            }
        }

        public string Fax
        {
            get { return _fax; }
            set
            {
                _fax = value;
                Notify( "Fax" );
            }
        }

        public Address Address
        {
            get { return _address; }
            set
            {
                _address = value;
                Notify( "Address" );
            }
        }
    
    #endregion (Properties)


        internal Customer Clone()
        {
            // Perform a shallow copy of all value fields...
            Customer copy = (Customer)MemberwiseClone();

            // Then, make deep copies of any reference fields...
            copy.Address = Address.Clone();

            return copy;
        }


        private void Notify( string strNotification )
        {
            if( PropertyChanged != null )
            {
                PropertyChanged( this, new PropertyChangedEventArgs( strNotification ) );
            }
        }
    }
}
